package com.fcscs.cservice.dao.jdbc;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Repository;

import com.fcscs.cservice.dao.MiscCronJobDao;
import com.mchange.v2.c3p0.PooledDataSource;

@Repository("miscCronJobDaoJdbc")
public class MiscCronJobDaoJdbc implements MiscCronJobDao {

	private static Logger LOG = Logger.getLogger(MiscCronJobDaoJdbc.class);

	private SimpleJdbcTemplate templ;

	@Autowired
	protected MiscCronJobDaoJdbc(@Qualifier("dataSourceMisc") PooledDataSource ds) {
		templ = new SimpleJdbcTemplate(ds);
	}

	@Override
	public void atomicBatchUpdate(Map<String, Object> params) {
		try {
			templ.update("delete from rc_attachment", new HashMap<String, Object>());
		} catch (Exception e) {
			LOG.error("Error locking row", e);
		}
	}

}
